/*
 * 专门为面板添加事件控制
 * @memberOf {TypeName} 
 */
Ext.define("AM.controller.deptController", {
	extend: 'Ext.app.Controller',
	init: function() {
		this.control({
			//xpath方式获取某个面板上的标签
			"deptTree button[id='allOpen']":　{
				click: function(b, e) {  //添加单击事件
					var tree = b.ownerCt.ownerCt;
					tree.expandAll();  //展开所有
				}
			},
			"deptTree button[id='allClose']":　{
				click: function(b, e) {
					var tree = b.ownerCt.ownerCt;
					tree.collapseAll();
				}
			},
			"deptTree button[id='add']":　{
				click: function(b, e) {
					//获取面板对象
					var tree = b.ownerCt.ownerCt;
					//找到被选中的节点
					var nodes = tree.getChecked();
					if (nodes.lenght == 1) {
						var node = nodes[0];
						node.appendChild({  //添加一个节点
							id: '010001',
							checked: false,
							text: '技术add部',
							leaf: true
						});
					} else {
						alert("请选择一个节点！");
					}
				}
			},
			"deptTree": {
				itemclick: function(tree, record, item, index, e, opts) {
					alert(record.get('id'));
				}
			}
		});
	},
	views: ['deptView'],  //关联view层
	stores: ['deptStore'],  //关联store层
	models: []
});